using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Entities;
using BUS;
using Utility;
public partial class User_ChiTietSanPham : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            LoadData();
        LoadData_dulieu();
    }

    private void LoadData()
    {
      //  tbHinhAnh.tbHinhAnhCollections ha_collection = tbHinhAnhBUS.GetByIDSP(3);
      //  Repeater1.DataSource = ha_collection;
      ////  Repeater2.DataSource = ha_collection;

      //  Repeater1.DataBind();
     //   Repeater2.DataBind();


        int id = int.Parse(Request.QueryString["id"].ToString());
        Criteria cri = new Criteria();
        //int total = 0;
        cri.add(Condition.AND, tbHinhAnhEntities.tbHinhAnhEntitiesColumns.MaSP, Condition.EQUAL, int.Parse(id.ToString()));
        tbHinhAnhEntities.tbHinhAnhEntitiesCollection hacollection = tbHinhAnhBUS.GetAll();

        Repeater1.DataSource = hacollection;
        Repeater1.DataBind();

    }
    private void LoadData_dulieu()
    {
        //int id = int.Parse(Request.QueryString["id"].ToString());
        //tbHinhAnh.tbHinhAnhCollections ha_collection = tbHinhAnhBUS.GetByIDSP(3);
        //tbSanPham sanpham = tbSanPhamBUS.GetByID(3);

        int id = int.Parse(Request.QueryString["id"].ToString());
        tbSanPhamEntities sanpham = tbSanPhamBUS.GetByID(id);
        if (sanpham != null)
        {
            lit_IDSP.Text = id.ToString();
            lit_TenSP.Text = sanpham.TenSP;
            lit_giaban.Text = sanpham.GiaBan.ToString();
            lit_gt_thuc.Text = sanpham.GiaGoc.ToString();
            lit_mota_sp.Text = sanpham.MoTa;
            lit_sl_ban.Text = sanpham.SLBan.ToString();
            lit_sl_daban.Text = sanpham.SLCon.ToString();           
            tbLoaiSanPhamEntities loai = tbLoaiSanPhamBUS.GetByID(sanpham.MaLoai);
            if (loai != null)
            {
                lit_loai.Text = loai.TenLoai.ToString();
            }

            tbTrangThai_SanPhamEntities tt_sp = tbTrangThai_SanPhamBUS.GetByID(sanpham.MaTT);
            if (tt_sp != null)
            {
                lit_trang_thai.Text = tt_sp.TenTT.ToString();
            }
        }
    }
}
